#include <bits/stdc++.h>
using namespace std;

int sudoku[10][10];

int ans;

//桶
int b1[10][5]; //行
int b2[10][5]; //列
int b3[10][5]; //块


void dfs(int x,int y) {
    if(x > 4) {
        ans++;
        return ;
    }

    int block = (x-1) / 2 * 2 + (y-1) / 2 +1;
    for(int i = 1;i<=4;i++) {

        if( b1[x][i] ==0 && b2[y][i] == 0 && b3[block][i] == 0) {
            int nx = x;
            int ny = y+1;
            if( ny > 4) {
                ny = 1;
                nx++;
            }
            b1[x][i] = 1;
            b2[y][i] = 1;
            b3[block][i] = 1;
            dfs(nx,ny);
            b1[x][i] = 0;
            b2[y][i] = 0;
            b3[block][i] = 0;
        }

    }
}

int main () {
    dfs(1,1);
    cout << ans;
    return 0;
}
